package com.magicode.cms.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.magicode.cms.dao.INewsDao;
import com.magicode.cms.entiy.base.News;
import com.magicode.cms.entiy.base.Tag;
import com.magicode.cms.service.INewsService;
import com.magicode.portal.common.assist.news.TagNewInfo;

@Service("newsService")
public class NewsServiceImpl implements INewsService {

	@Autowired
	@Qualifier("newsDao")
	private INewsDao newsDao;
	
	@Override
	public List<News> list() {
		return newsDao.list();
	}

	@Override
	public News get(String id) {
		return newsDao.get(id);
	}

	@Override
	public void delete(String id) {
		newsDao.delete(id);
	}

	@Override
	public News save(News news) {
		return newsDao.save(news);
	}
	
	@Override
	public News update(News news) {
		return newsDao.update(news);
	}

	@Override
	public List<Map<String, Object>> getNewsTags(String newid) {
		News news = this.get(newid);
		return newsDao.getTagsByNewsId(news.getId());
	}

	@Override
	public TagNewInfo getTagNewInfo(String tagid) {
		// TODO Auto-generated method stub
		return newsDao.getTagNewInfo(tagid);
	}

}
